<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/axios/0.19.0/axios.js"></script>
</head>

<body>

    <script>
        // var csrftoken = Cookies.get('csrfToken');
        
        function getCookie(name) {
            let strcookie = document.cookie;//获取cookie字符串
            let arrcookie = strcookie.split("; ");//分割
            //遍历匹配
            for (let i = 0; i < arrcookie.length; i++) {
                let arr = arrcookie[i].split("=");
                if (arr[0] == name) {
                    return arr[1];
                }
            }
            return "";
        }
        var csrftoken = getCookie('csrfToken');

        axios({
            method: 'post',
            url: 'http://localhost:7001/web/api/cat',
            headers: {'x-csrf-token': csrftoken},
            data: {
                firstName: 'Fred',
                lastName: 'Flintstone'
            }
        }).then((data) => {
            console.log(data);
        })
    </script>
</body>

</html>